package com.zhengze;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

// 非贪婪匹配：尽可能少的匹配
public class Demo8 {
    public static void main(String[] args) {
        String re = "(\\d??)(1*)";
        // 获取Pattern对象
        Pattern pattern = Pattern.compile(re);
        // 获取Matches对象
        Matcher matcher = pattern.matcher("11111111");
        if (matcher.matches()) {
            System.out.println("第一个子串：" + matcher.group(1));
            System.out.println("第二个子串：" + matcher.group(2));
        }
    }
}
